<?php

namespace App\Http\Controllers\Property;

use App\Common\json;
use App\Common\SmsClient;
use App\Http\Controllers\Controller;
//use App\Libraries\upload;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Common\push;
use Psy\Test\Exception\RuntimeExceptionTest;

class PushController extends  Controller{


/*    private    $sms_url 		= "http://www.api.zthysms.com/sendSms.do";//提交地址
    private    $username 	    = "nbsqyl2017hy";//用户名
    private    $password 	    = "ZTnbsqyl20178520";//原密码
    public function pushcs(Request $request){
        if($request ->isMethod('post')) {
            $rand = rand(1000, 9999);
            $sms = new SmsClient($this->sms_url,$this ->username, $this->password);
            $data = array(
                'content' 	=> "小主，您正在加入智慧生态社区栖云里，验证码:$rand,请妥善保管，这是我们之间的约定哦 【栖云里】",//短信内容
                'mobile' 	=> '18814818096',//手机号码
                'productid' => '887361',//产品id
                'xh'		=> ''//小号
            );
            $sms ->data = $data;
            $value  = $sms ->sendSMS('post');
            return $value;
        }
    }*/

    public function pushcs(Request $request){
        if($request ->isMethod('post')){
            $push      = new push();
/*            $id        = $request ->input('user_id');
           $array_ids = explode(',',$id);
            $result = array();
            foreach($array_ids as $k =>$v){
                $res = DB::table('user')->select('phone')->where('user_id','=',$v)->first();
                $result[] =$res->phone;
            }*/
/*           $arr =array('');
          // foreach ($result as $value){
                $push ->send_pub($result,'你有一条推送信息','2');
         //  }
        }*/
    }





    //测试推送
   /* public function pushcs(Request $request){
        if($request ->isMethod('post')){
                $push  = new push();
                $id        = $request ->input('user_id');
                $array_ids = explode(',',$id);
                $result = array();
                foreach($array_ids as $k =>$v){
                    $res = DB::table('user')->select('phone')->where('user_id','=',$v)->first();
                    $result[] =$res->phone;
                }
                for ($i =0; $i<count($result);$i++){
                    $pv = $push ->send_pub($result[$i],'你有一条新信息');
                }
                return $pv;
        }
    }*/




}